home *** CD-ROM | disk | FTP | other *** search
- #!/bin/vtcl
- # ---------------------------------------------------------------------
- # Copyright 1994 by SCO, Inc.
- # Permission to use, copy, modify, distribute, and sell this software
- # and its documentation for any purpose is hereby granted without fee,
- # provided that the above copyright notice appear in all copies and that
- # both that copyright notice and this permission notice appear in
- # supporting documentation, and that the name of SCO not be used in
- # advertising or publicity pertaining to distribution of the software
- # without specific, written prior permission. SCO makes no
- # representations about the suitability of this software for any
- # purpose. It is provided "as is" without express or implied warranty.
- # ---------------------------------------------------------------------
-
- # Demo : msg.tcl
- # Description : Demo of all the Motif dialog boxes.
- #
- # Note : Good example of building a command, later to be
- # invoked via the "eval" command.
-
- # Close connection and exit Visual Tcl interpreter.
- proc CloseCB { cbs } {
- VtClose; exit 0
- }
- #
- # Minimal test of messagebox the idea here is to display all the different
- # types at once with different options, like new lines, blank titles, etc.
- #
-
- proc LabelText {parent label text} {
- VtLabel $parent.label \
- -label $label
- set textWidget [VtText $parent.textWidget \
- -value $text \
- -verticalScrollBar True \
- -rightSide FORM \
- -rows 3 \
- ]
-
- return $textWidget
- }
-
- # Grab the text stored in the text widget,
- # Build the dialog, passing the button option (i.e. -ok, -cancel, -help)
- # stored in the userData field.
- #
- proc mkDlog {cmd buttonList textWidget cbs} {
- set txt [VtGetValues $textWidget -value]
- set parent [keylget cbs widget]
-
- lappend cmd $parent.$cmd -message $txt
-
- # look at each button (ok, cancel, help) and determine
- # if it should be displayed.
- #
- foreach button $buttonList {
- if { [VtGetValues $button -value]} {
- set resource [VtGetValues $button -userData]
- lappend cmd $resource
- }
- }
-
- set dialog [eval $cmd]
- VtShow $dialog
- }
-
- # Open connection to the Visual Tcl display engine.
- #
- set app [VtOpen msg]
-
- # Build the main dialog.
- #
- set dlog [VtFormDialog $app.dlog \
- -title "Motif Message Dialogs" \
- -okLabel Quit \
- -okCallback CloseCB \
- -help \
- ]
-
- set textWidget [LabelText $dlog "Message Title" "<Put your text here!>"]
-
- set rc [VtRowColumn $dlog.rc \
- -leftSide FORM \
- -below $textWidget \
- -horizontal \
- ]
-
- # We'll store the option inside each widget using the userData field.
- #
- foreach button { { OK -ok } { Cancel -cancel } { Help -help } } {
- set name [lindex $button 0]
- set option [lindex $button 1]
- set buttonWidget [VtToggleButton $rc.$name \
- -value 1 \
- -userData $option\
- ]
- lappend buttons $buttonWidget
- }
- set buttonList [list $buttons]
-
- set dialogCommandList \
- "VtMessageDialog
- VtErrorDialog
- VtWarningDialog
- VtInformationDialog
- VtQuestionDialog
- VtWorkingDialog"
-
- set rcb [VtRowColumn $dlog.rcb \
- -horizontal \
- -packing COLUMN \
- -numColumns 2\
- -MOTIF_topOffset 10 \
- ]
-
- # Build the set of dialog-invoking buttons.
- #
- foreach dialogCommand $dialogCommandList {
- VtPushButton $rcb.$dialogCommand \
- -callback "mkDlog $dialogCommand $buttonList $textWidget"
- }
-
- VtShowDialog $dlog
- VtMainLoop
-
-